home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue60 / Alfresco / TstHuff.dpr < prev   
Encoding:
Text File  |  2000-06-25  |  1.6 KB  |  74 lines

  1. program TstHuff;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. uses
  6.   SysUtils,
  7.   Classes,
  8.   AABufStm,
  9.   AAHuffmn;
  10.  
  11. var
  12.   InStr  : TFileStream;
  13.   OutStr : TFileStream;
  14.  
  15.   InBufStm  : TaaBufferedStream;
  16.   OutBufStm : TaaBufferedStream;
  17. begin
  18.   try
  19.     writeln('Huffman compression test');
  20.     writeln('Compressing...');
  21.     InStr := TFileStream.Create('LLL.TXT', fmOpenRead);
  22.     try
  23.       OutStr := TFileStream.Create('LLL.HUF', fmCreate);
  24.       try
  25.         InBufStm := TaaBufferedStream.Create(InStr, 16*1024);
  26.         try
  27.           OutBufStm := TaaBufferedStream.Create(OutStr, 16*1024);
  28.           try
  29.             HuffmanCompress(InBufStm, OutBufStm);
  30.           finally
  31.             OutBufStm.Free;
  32.           end;
  33.         finally
  34.           InBufStm.Free;
  35.         end;
  36.       finally
  37.         OutStr.Free;
  38.       end;
  39.     finally
  40.       InStr.Free;
  41.     end;
  42.     writeln('Done');
  43.  
  44.     writeln('Decompressing...');
  45.     InStr := TFileStream.Create('LLL.HUF', fmOpenRead);
  46.     try
  47.       OutStr := TFileStream.Create('LLL.HTX', fmCreate);
  48.       try
  49.         InBufStm := TaaBufferedStream.Create(InStr, 16*1024);
  50.         try
  51.           OutBufStm := TaaBufferedStream.Create(OutStr, 16*1024);
  52.           try
  53.             HuffmanDecompress(InBufStm, OutBufStm);
  54.           finally
  55.             OutBufStm.Free;
  56.           end;
  57.         finally
  58.           InBufStm.Free;
  59.         end;
  60.       finally
  61.         OutStr.Free;
  62.       end;
  63.     finally
  64.       InStr.Free;
  65.     end;
  66.     writeln('Done');
  67.   except
  68.     on E:Exception do
  69.       writeln(E.Message);
  70.   end;
  71.   readln;
  72. end.
  73.  
  74.